﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LINQExampleStudents
{
    public class StudentMethods
    {
        //Extracts all students whose first name is before its last name alphabetically
        public static IEnumerable<Student> ExtractStudentsByName(IEnumerable<Student> students)
        {
            IEnumerable<Student> newList =
                from student in students
                where student.FirstName.CompareTo(student.LastName) < 0
                select student;
            return newList;
        }

        //Extracts all students with age between 18 and 24
        public static IEnumerable<Student> ExtractStudentsByAge(IEnumerable<Student> students)
        {
            IEnumerable<Student> newList =
                from student in students
                where student.Age >= 18 && student.Age <= 24
                select student;
            return newList;
        }
    }
}
